<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>jQuery基础教程之效果-淡入淡出</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <style>
        div{
            text-align: center;
        }
        #main{
            width: 180px;
            height: auto;
            margin: 0px auto;
            padding: 0px;
            cursor: pointer;
        }
        .title{
            width: 100%;
            height: 36px;
            font-weight: bold;
            line-height: 36px;
            margin: 0px auto;
            background-color: lightcyan;
        }
        .submenu{
            width: 100%;
            height: auto;
            margin: 0px auto;
            padding: 0px;
            display: none;
        }
        .submenu .item{
            width: 100%;
            height: auto;
            padding: 5px 0px;
            background-color: lightyellow;
        }
    </style>
</head>
<body>
<h1>淡入和淡出</h1>
<hr>

<div id="main">
    <div class="title">课程</div>
    <div class="submenu">
        <div class="item">后端</div>
        <div class="item">前端</div>
        <div class="item">运维</div>
        <div class="item">大数据</div>
        <div class="item">UI</div>
    </div>
</div>

<script>
    $(function(){
        $(".title").mouseover(function(){
            $(".submenu").fadeIn("slow");
        })

        $("#main").mouseleave(function(){
            $(".submenu").fadeOut(1000);
        })
        $(".item").click(function(){
            console.log($(this).text());
        })
    })
</script>

</body>
</html>


